package ar.edu.unq.persistencia.commands;

import java.util.ArrayList;
import java.util.List;

/**
 * TODO: description
 */
public class CrearEntidadCommand<T> extends Command<T> {

    private List<T> entitiesToCreate = new ArrayList<T>();

    public List<T> getEntitiesToCreate() {
        return this.entitiesToCreate;
    }

    public void setEntitiesToCreate(final List<T> entitiesToCreate) {
        this.entitiesToCreate = entitiesToCreate;
    }

    public CrearEntidadCommand(final Class clazz) {
        super(clazz);
    }

    public void run() {
        for (T entity : this.getEntitiesToCreate()) {
            this.getSession().saveOrUpdate(entity);
        }
    }

}
